package com.hele.sts.pub;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hele.sts.dao.DbClose;

public class SelectOption
{
	private static final Logger logger = LoggerFactory.getLogger(SelectOption.class);
  public static String getCode(String tbName, String content)
  {
    String contentVal = content;
    Connection conn = null;
	PreparedStatement pstmt = null;
	String sql = null;
	ConnectDB connsyb = null;
	ResultSet rs = null;
	sql = "select code from " + tbName + " where  content = '" + content + "' ";
	connsyb = SpringContextHolder.getBean(ConnectDB.class);
	
	try {
		conn = connsyb.getConnection();
		pstmt = conn.prepareStatement(sql);
		rs = pstmt.executeQuery();
	    while (rs.next()) {
	    	contentVal = rs.getString("code");
	    }
	    return contentVal;
	} catch (SQLException e) {
		logger.info("db error", e);
	} finally {
		DbClose.freeResultSet(rs);
		DbClose.freePreparedStatement(pstmt);
		DbClose.freeConnection(conn);
	}
    return contentVal;
  }
  
  public static String getCodeVal(String tbName, String codeVal)
    throws SQLException
  {
	  String contentVal = codeVal;
	    Connection conn = null;
		PreparedStatement pstmt = null;
		String sql = null;
		ConnectDB connsyb = null;
		ResultSet rs = null;
		sql = "select content from " + tbName + " where  code = '" + codeVal + "' ";
		connsyb = SpringContextHolder.getBean(ConnectDB.class);
		conn = connsyb.getConnection();
		try {
			pstmt = conn.prepareStatement(sql);
			rs = pstmt.executeQuery();
		    while (rs.next()) {
		    	contentVal = rs.getString("content");
		    }
		    return contentVal;
		} catch (SQLException e) {
			logger.info("db error", e);
		} finally {
			DbClose.freeResultSet(rs);
			DbClose.freePreparedStatement(pstmt);
			DbClose.freeConnection(conn);
		}
	    return contentVal;
  }
  
  public static String getCodeVal(String tbName, String colCode, String colContent, String codeVal)
    throws SQLException
  {
    ResultSet rs = null;
    String contentVal = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select " + colContent + " from " + tbName + " where  " + colCode + "='" + codeVal + "'";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        contentVal = rs.getString(1);
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return contentVal;
  }
  
  public static String getCodeValGxdw(String codeVal)
  {
    String contentVal = codeVal;
    return contentVal;
  }
  
  public static String getCodeValWhole(String tbName, String colCode, String colContent, String codeVal, String DataS)
    throws SQLException
  {
    ResultSet rs = null;
    String contentVal = "";
    SqlQuery sqlquery = new SqlQuery(DataS);
    String sqlstr = "";
    sqlstr = "select " + colContent + " from " + tbName + " where  " + colCode + "='" + codeVal + "'";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        contentVal = rs.getString(1);
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return contentVal;
  }
  
  public static String getCodeValWhole(String tbName, String codeVal, String DataS)
    throws SQLException
  {
    ResultSet rs = null;
    String contentVal = "";
    SqlQuery sqlquery = new SqlQuery(DataS);
    String sqlstr = "";
    sqlstr = "select content from " + tbName + " where  code = '" + codeVal + "' ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        contentVal = rs.getString(1);
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return contentVal;
  }
  
  public static String getHkBmZrrList(String gxdw)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select a.code,a.content from hk_bm_zrr a,hk_bm_xcz b where a.xcz=b.code  and b.gxdwdm='" + gxdw + "'  order by a.code ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(2) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionList(String tbName)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select code,content from " + tbName + " order by code ";
    if (tbName.equals("hk_bm_jglb")) {
      sqlstr = sqlstr + " DESC";
    }
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(2) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionList(String tbName, String type, String dlCode, int length)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    if (type.equals("spdl")) {
      sqlstr = "select code,content from " + tbName + " Where length(code)=" + length + " order by code ";
    } else if (type.equals("spxl")) {
      sqlstr = "select code,content from " + tbName + " Where subStr(code,1,2)='" + dlCode + "' and length(code) > " + length + " order by code ";
    }
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(2) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionList(String lx, String nbxh)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    String tableName = "";
    if (lx.equals("spdl")) {
      tableName = "sc_bm_zysp";
    } else {
      tableName = "sc_bm_zyspzl";
    }
    sqlstr = "select distinct a.code,a.content from " + tableName + " a,sc_bm_scdlsp b" + " where b." + lx + "=a.code and b.scnbxh in (select distinct(scnbxh) from sc_hz_jyhtwqk where jyhnbxh = " + nbxh + ") order by code ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      if (!rs.next()) {
        optionList = getOptionList(tableName);
      } else {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(2) + "</option>";
      }
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(2) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionList(String tbName, String colName1, String colName2, String colValue1)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    String selectedString = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select " + colName1 + "," + colName2 + " from " + tbName + " order by " + colName1 + " ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null) {
      while (rs.next())
      {
        if (rs.getString(1).equals(colValue1)) {
          selectedString = "selected";
        } else {
          selectedString = "";
        }
        optionList = optionList + "<option value='" + rs.getString(1) + "'" + selectedString + " >" + rs.getString(2) + "</option>";
      }
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionList(String tbName, String colName1, String colName2, String colName3, String gxdwVal)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select " + colName1 + "," + colName2 + " from " + tbName + " where " + colName3 + "='" + gxdwVal + "' order by " + colName1 + " ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(2) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionList(String tbName, String colName1, String colName2)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select " + colName1 + "," + colName2 + " from " + tbName + " group by " + colName1 + "," + colName2 + " ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(2) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionListByGxdw(String tbName, String colName1, String colName2, String bz, String gxdw, String colValue1)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    String selectedString = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select " + colName1 + "," + colName2 + " from " + tbName;
    if (bz == null) {
      bz = "";
    }
    if (gxdw == null) {
      gxdw = "";
    }
    if (bz.equals("41")) {
      sqlstr = sqlstr + " where gxdwdm = '" + gxdw + "'";
    }
    sqlstr = sqlstr + " order by " + colName1 + " ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null) {
      while (rs.next())
      {
        if (rs.getString(1).equals(colValue1)) {
          selectedString = "selected";
        } else {
          selectedString = "";
        }
        optionList = optionList + "<option value='" + rs.getString(1) + "'" + selectedString + " >" + rs.getString(2) + "</option>";
      }
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionListByGxdw(String tbName, String bz, String gxdw)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select code,content from " + tbName;
    if (bz == null) {
      bz = "";
    }
    if (bz.equals("41")) {
      sqlstr = sqlstr + " where gxdwdm like '%" + gxdw + "%'";
    }
    sqlstr = sqlstr + " order by code ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(2) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionListGxdw(String Gxdw)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "SELECT scmc FROM sc_hz_scdj where scgxfl like '%" + Gxdw + "%'";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(1) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionListWhole(String tbName, String DataS)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery(DataS);
    String sqlstr = "";
    sqlstr = "select code,content from " + tbName + " order by code ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(2) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionListWhole(String tbName, String colName1, String colName2, String DataS)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery(DataS);
    String sqlstr = "";
    sqlstr = "select " + colName1 + "," + colName2 + " from " + tbName + " order by " + colName1 + " ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(2) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionListWhole(String tbName, String colName1, String colName2, String colValue1, String DataS)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    String selectedString = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select " + colName1 + "," + colName2 + " from " + tbName + " order by " + colName1 + " ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null) {
      while (rs.next())
      {
        if (rs.getString(1).equals(colValue1)) {
          selectedString = "selected";
        } else {
          selectedString = "";
        }
        optionList = optionList + "<option value='" + rs.getString(1) + "'" + selectedString + " >" + rs.getString(2) + "</option>";
      }
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionListWhole(String tbName, String colName1, String colName2, String colName3, String gxdwVal, String DataS)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery(DataS);
    String sqlstr = "";
    sqlstr = "select " + colName1 + "," + colName2 + " from " + tbName + " where " + colName3 + "='" + gxdwVal + "' order by " + colName1 + " ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(2) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionListWithVal(String tbName)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select code,content from " + tbName + " order by code ";
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(1) + rs.getString(2) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
  
  public static String getOptionList_jcnr(String code, String content, String table, String where)
    throws SQLException
  {
    ResultSet rs = null;
    String optionList = "";
    SqlQuery sqlquery = new SqlQuery();
    String sqlstr = "";
    sqlstr = "select " + code + "," + content + " from " + table + " where " + where;
    rs = sqlquery.getResultSet(sqlstr);
    if (rs != null)
    {
      while (rs.next()) {
        optionList = optionList + "<option value='" + rs.getString(1) + "'>" + rs.getString(2) + "</option>";
      }
      rs.close();
    }
    sqlquery.close();
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException1) {}
    try
    {
      if (rs != null) {
        rs.close();
      }
      if (sqlquery != null) {
        sqlquery.close();
      }
    }
    catch (Exception localException2) {}
    return optionList;
  }
}
